// 销售统计
import instance from '@/utils/request'

const getTurnoverStatistics = (beginTime, endTime) => {
  // 将日期转换为指定格式的字符串，例如：yyyy-MM-dd
  const formattedBeginDate = new Date(beginTime).toISOString().split('T')[0]
  const formattedEndDate = new Date(endTime).toISOString().split('T')[0]

  return instance.get('/statistics/getTurnoverStatistics', {
    params: {
      begin: formattedBeginDate,
      end: formattedEndDate
    }
  })
}

export const getSaleStatistics = (beginTime, endTime) => {
  // 将日期转换为指定格式的字符串，例如：yyyy-MM-dd
  const formattedBeginDate = new Date(beginTime).toISOString().split('T')[0]
  const formattedEndDate = new Date(endTime).toISOString().split('T')[0]

  return instance.get('/statistics/getSaleStatistics', {
    params: {
      begin: formattedBeginDate,
      end: formattedEndDate
    }
  })
}

const getSalesProportionOfGoods = () => {
  return instance.get('/statistics/salesProportionOfGoods')
}

// 获取库存数，销售订单数，采购订单数
const getAllCount = () => {
  return instance.get('/statistics/getAllCount')
}

export { getTurnoverStatistics, getSalesProportionOfGoods, getAllCount }
